import request from '@/utils/request'
// 获取-商品列表
export const getGoodslist = (params) => {
  return request({
    method: 'GET',
    url: '/goods',
    params
  })
}
// 添加-商品
export const addGoodslist = (data) => {
  return request({
    method: 'POST',
    url: '/goods',
    data
  })
}
// 获取-商品分类列表
export const getCategories = () => {
  return request({
    method: 'GET',
    url: '/categories'
  })
}
// 获取-商品参数和属性
export const getGoodsType = (id, params) => {
  return request({
    method: 'GET',
    url: `/categories/${id}/attributes`,
    params
  })
}
// 删除商品
export const delGoods = (id) => {
  return request({
    method: 'DELETE',
    url: `/goods/${id}`
  })
}
// 添加动态参数
export const addGoods = (id, data) => {
  return request({
    method: 'POST',
    url: `categories/${id}/attributes`,
    data
  })
}
// 编辑动态参数
export const editGoods = (id, attrid, data) => {
  return request({
    method: 'PUT',
    url: `categories/${id}/attributes/${attrid}`,
    data
  })
}
// 删除动态参数
export const deltGoods = (id, attrid) => {
  return request({
    method: 'DELETE',
    url: `categories/${id}/attributes/${attrid}`
  })
}
// 获得商品分类
export const getGoodsClass = (params) => {
  return request({
    method: 'GET',
    url: '/categories',
    params
  })
}
/// 添加分类
export const addGoodsClass2 = (data) => {
  return request({
    method: 'POST',
    url: '/categories',
    data
  })
}
// 编辑分类信息
export const editGoodsClass = (pid, data) => {
  return request({
    method: 'PUT',
    url: `/categories/${pid}`,
    data
  })
}
// 删除商品分类
export const delGoodsClass = (pid) => {
  return request({
    method: 'DELETE',
    url: `/categories/${pid}`
  })
}
